<template>
	<view class="manage">
		<!-- 	<view class="card">
			<view class="card-tit">组织管理</view>
			<view class="flex align items">
				<navigator url="/pages/manage/list" hover-class="none" class="item">
					<image src="../../static/images/manage/icon1.png"></image>
					<view>总监管理</view>
				</navigator>
				<view class="item">
					<image src="../../static/images/manage/icon1.png"></image>
					<view>BDM管理</view>
				</view>
				<view class="item">
					<image src="../../static/images/manage/icon1.png"></image>
					<view>BD管理</view>
				</view>
			</view>
		</view> -->
		<view style="font-size: 28rpx;padding: 20rpx 20rpx 0;color: #FF6543;">
			<view v-if="adminUser!=''" style="margin-right: 20rpx;">已登录总账号：{{adminUser}}</view>
			<view><text v-if="adminUser!=''"></text>子账号：{{info.username}}</view>
		</view>
		<view class="card">
			<view class="card-tit">业务管理</view>
			<view class="flex align items">
				<navigator url="/pages/task/index" hover-class="none" class="item" v-if="taskManage_S">
					<image src="../../static/images/manage/icon6.png"></image>
					<view>任务发布</view>
				</navigator>
				<navigator url="/pages/manage/taskList" hover-class="none" class="item" v-if="taskManage_S">
					<image src="../../static/images/manage/icon6.png"></image>
					<view>任务管理</view>
				</navigator>
				<navigator url="/pages/manage/submit/submit" hover-class="none" class="item" v-if="taskManage_S">
					<image src="../../static/images/manage/icon6.png"></image>
					<view>提交审核</view>
				</navigator>
				<navigator hover-class="none" url="/pages/manage/store" class="item" v-if="storeManage_S">
					<image src="../../static/images/manage/icon2.png"></image>
					<view>商户管理</view>
				</navigator>
				<!-- <navigator hover-class="none" url="/pages/manage/balance" class="item">
					<image src="../../static/images/manage/icon3.png"></image>
					<view>余额管理</view>
				</navigator> -->
				<navigator url="/pages/manage/check" hover-class="none" class="item" v-if="taskManage_S">
					<image src="../../static/images/manage/icon5.png"></image>
					<view>商家选号</view>
				</navigator>
				<navigator url="/pages/manage/material" hover-class="none" class="item" v-if="material_S">
					<image src="../../static/images/manage/icon6.png"></image>
					<view>素材管理</view>
				</navigator>
			</view>
		</view>
		<view class="card" v-if="storeManage_S">
			<view class="card-tit">财务管理</view>
			<navigator url="/pages/manage/payLog" hover-class="none" class="flex align items">
				<view class="item">
					<image src="../../static/images/manage/icon4.png"></image>
					<view>成本管理</view>
				</view>
			</navigator>
		</view>
		<view class="outBtn" @click="toOut()">切换账号</view>
	</view>
</template>

<script>
	import {
		companyInfo,
		adminInfo2
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				show: false,
				role_id: '',
				material_S: false,
				storeManage_S: false,
				taskManage_S: false,
				info: '',
				adminUser: ''
			};
		},
		onShow() {
			this.material_S = false
			this.storeManage_S = false
			this.taskManage_S = false
			this.getInfo()
		},
		methods: {
			async getInfo() {
				const result = await companyInfo()
				if (result.code == 1) {
					this.info = result.data
					this.role_id = result.data.role_id
					let arr = result.data.permission_list
					if (arr.length != 0) {
						arr.forEach(item => {
							if (item.permission_mark == 'materialManage') { //素材管理
								this.material_S = true
							}
							if (item.permission_mark == 'storeManage') { //商户管理
								this.storeManage_S = true
							}
							if (item.permission_mark == 'taskManage') { //任务管理
								this.taskManage_S = true
							}
						})
					}
				} else {

				}
				const result2 = await adminInfo2()
				if (result2.code == 1) {
					this.adminUser = result2.data.username
				}
			},
			toOut() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.outBtn {
		background: #FF6543;
		color: white;
		font-size: 28rpx;
		width: fit-content;
		padding: 12rpx 40rpx;
		margin: 100rpx auto;
		border-radius: 5rpx;
	}

	.card {
		background: white;
		box-shadow: 1rpx 1rpx 5rpx 1rpx gainsboro;
		border-radius: 12rpx;
		padding: 16rpx 24rpx;
		margin: 30rpx 24rpx;

		.card-tit {
			font-size: 32rpx;
			font-weight: bold;
			margin-bottom: 30rpx;
		}

		.items {
			flex-wrap: wrap;
			font-size: 28rpx;

			.item {
				margin-right: 43rpx;
				text-align: center;
				margin-bottom: 20rpx;

				image {
					width: 90rpx;
					height: 90rpx;
				}
			}
		}
	}
</style>